/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rcfi.lankaweb.linklk.validate;

/**
 *
 * @author priyantha
 */
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
import com.rcfi.lankaweb.linklk.model.user;

public class userValidator implements Validator {

    @Override
    public boolean supports(Class<?> clazz) {
        return user.class.isAssignableFrom(clazz);
    }

    @Override
    public void validate(Object target, Errors errors) {
                ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName",
                "name.required");

          ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName",
                "name.required");

        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password",
                "password.required");

        ValidationUtils.rejectIfEmpty(errors, "gender", "gender.required");

        ValidationUtils.rejectIfEmpty(errors, "np", "np.required");

          ValidationUtils.rejectIfEmptyOrWhitespace(errors, "dob",
                "dob.required");

        ValidationUtils.rejectIfEmpty(errors, "country", "country.required");

          ValidationUtils.rejectIfEmptyOrWhitespace(errors, "mobile",
                "mobile.required");

        user user = (user) target;

    }
}
